package com.shawn.admin.controller;

import com.shawn.admin.service.DashBoardService;
import com.shawn.commons.utils.RC;
import com.shawn.model.vo.AnalysisVo;
import com.shawn.model.vo.DistributionVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;

/**
 * @author wjy
 * @date 2022年 11月 09日 16:25
 */
@RestController
@RequestMapping("/dashboard")
public class DashBoardController {
    @Autowired
    private DashBoardService dashBoardService;


    /**
     * 得到分布
     *
     * @param sd sd
     * @param ed 艾德
     * @return {@link ResponseEntity}
     */
    @GetMapping("/distribution")
    public ResponseEntity getDistribution(Long sd,Long ed){
        DistributionVo vo = dashBoardService.getDistribution(sd,ed);
        return ResponseEntity.ok(vo);
    }

    @GetMapping("/summary")
    public ResponseEntity getAnalysisResults(){
        AnalysisVo analysisVo = dashBoardService.getAnalysisResults();
        return ResponseEntity.ok(analysisVo);
    }

    /**
     * 获取指定时间周期内的每一天的类型数量以及去年的同比数据
     *
     * @param sd   起始时间
     * @param ed   终止时间
     * @param type 类型 101 新增 102 活跃用户 103 次日留存率
     * @return {@link ResponseEntity}
     */
    @GetMapping("/users")
    public ResponseEntity getDashboardData(Long sd,Long ed,String type){
        return dashBoardService.getDashboardData(sd,ed,type);
    }
}

